package com.example.back.controller;

import com.example.back.service.ComponentValidationService;
import com.example.back.model.ConnectionValidationRequest;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/components")
@CrossOrigin(origins = "*")
public class ComponentController {

    private final ComponentValidationService validationService;
    
    public ComponentController(ComponentValidationService validationService) {
        this.validationService = validationService;
    }
    
    @PostMapping("/validate-connection")
    public boolean validateConnection(@RequestBody ConnectionValidationRequest request) {
        return validationService.canConnect(request.getSourceType(), request.getTargetType());
    }
} 